package thread;

public class DeamonThreadDemo {
    public static void main(String[] args) {
        Thread rose=new Thread("rose"){
            public void run() {
               for(int i=0;i<5;i++){
                   System.out.println("let me go!");
                   try {
                       Thread.sleep(1000);
                   } catch (InterruptedException e) {
                       e.printStackTrace();
                   }
               }
               System.out.println("啊啊啊ahahahaaaaaaaaa.....");
               System.out.println("蹦咚");
            }
        };

        Thread jack=new Thread("jack"){
            public void run(){
                for(int i=0;i<5;i++){
                    while(true){
                    System.out.println("You jump!I jump!");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                }
            }
        };

        rose.start();
        jack.setDaemon(true);
        jack.start();

        //while(true);//如果让主线程死循环，守护线程则不会被杀死
    }
}
